﻿#include "File.h"
#include "util/FileUtil.h"
#include "yzrutil.h"
#include <vector>

using namespace yzrilyzr_util;
using namespace yzrilyzr_lang;

namespace yzrilyzr_io{
	File::File(const String & parent, const String & child) :File(parent + "/" + child){}
	File::File(const File & parent, const String & child) :File(parent.getAbsolutePath() + "/" + child){}
	File::File(const String & path){
		this->path=path;
	}
	File::File(const char * path) :File(String(path)){}
	String File::getName() const{
		return FileUtil::name(getAbsolutePath());
	}
	String File::getParent() const{
		return FileUtil::parent(getAbsolutePath());
	}
	std::vector<File> File::listFiles()const{
		std::vector<String> str=list();
		std::vector<File> ls;
		for(const String & a : str){
			ls.push_back(File(a));
		}
		return ls;
	}

	File & File::operator=(const File & sp){
		path=sp.path;
		return *this;
	}
	File::File(const File & sp){
		path=sp.path;
	}
	String File::toString()const{
		return path;
	}
}